package lightswitch.code.connection;

import java.io.Serializable;
import java.util.Vector;

import lightswitch.client.code.model.MyTableModel;

public class QueryDataTransfering implements Serializable{
    /**  . */
    private static final long serialVersionUID = -3186428059484297436L;
    private Vector<Vector<Object>> dataVector;
    private Vector<String> nameVector;
    public boolean flagError = false;
    public QueryDataTransfering(Vector<Vector<Object>> data, Vector<String> name, boolean flagError){
        dataVector = data;
        nameVector = name;
        this.flagError = flagError; 
    }
    
    public QueryDataTransfering(){
        dataVector = new Vector<Vector<Object>>();
        nameVector = new Vector<String>();
    }
    
    public Vector<Object> getRow(int row){
        return dataVector.get(row);
    }
    
    public Object getValue(int row, int col){
        return dataVector.get(row).get(row);
    }
    
    public void setValue(int row, int col, Object value){
        Vector<Object> rowData = dataVector.get(row);
        rowData.set(col, value);
        dataVector.set(row, rowData);
    }

    public Vector<Vector<Object>> toDataTable() {
        return dataVector;
    }
    
    public MyTableModel convertToModel(){
        return new MyTableModel(this.nameVector, this.dataVector);
    }

    public boolean isEmpty() {
        return dataVector!=null && dataVector.size()==0;
    }
    
}

